package com.whir.rd.swd;

import java.sql.SQLException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.whir.ezoffice.customdb.common.util.DbOpt;

public class SendFlow2QMSNew extends SendFlow2QMS{
	
	private Map<String, String> proMap = urlMap();
	private String synchronousTransfer = (String)this.proMap.get("synchronousTransfer");
	 
	
	 public String pushStatusNew(String status, HttpServletRequest request){
	    System.out.println("=======SendFlowStatusToDoc-start=======");

	    String url = this.synchronousTransfer;

	    Map data = getFlowData(request.getParameter("infoId"));
	    checkData(data, status, request);
	    String soapXml = createSOAPXml(data);
	    String result = sendHttp(url, soapXml);
	    
	    //流程办理通知时 判断下是否同步成功  成功更新下状态
	    if("0".equals(status)&&result.indexOf("<code>200</code>")>-0){
	    	updateStatus(request.getParameter("infoId"));
	    }
	    System.out.println("=======SendFlowStatusToDoc-end=======");
	    return result;
	  }
	 
	 
	 public void updateStatus(String infoId){
		 DbOpt dbopt = new DbOpt();
		 String sql = "update whir$t3202 set whir$t3202_qmsSync = '已同步' where whir$t3202_id = ?";
		 try {
			dbopt.executeUpdate(sql,new Object[]{infoId});
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			try {
				dbopt.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		 
	 }
	 
}
